package com.mjr.webmanage.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
//@Aspect
//@Component
public class TimeAspect {

//    @Around("execution(* com.mjr.webmanage.controller.*.*(..))")
    @Around("execution(* com.mjr.webmanage.service.impl.*.*(..))")
    public Object RecordTime(ProceedingJoinPoint pjp) throws Throwable {
        log.info("-------->记录时间");
        long begin = System.currentTimeMillis();
        //  调用原始方法运行
        Object result = pjp.proceed();
        long end = System.currentTimeMillis();
        log.info("耗时：{} ms", end - begin);
        return result;
    }
}
